<?php
class searchController extends Controller{
	
	public function s(){
		return array('search');
	}
	public function index(){
        include($this->viewer_dir.'search/search_.php');
	}
	public function search(){
        
	}
	public function j(){
		alert('请输入搜索内容！');
		js("location.href='/mobile.php';");
		exit;
	}
	public function search_(){
		if(!$_GET) $this->j();
		
		$_type=trim($_GET['_type']);
		if(!in_array($_type,array('title','attr','word'))) $_type='title';
		
		$_kw=trim($_GET['_kw']);
		if(!$_kw) $this->j();
		if(utf8_strlen($_kw)<2) $this->j();
		
		$_kw=str_replace("%","\%",$_kw);
		$_kw=str_replace("_","\_",$_kw);
		
		$search = array("/union/i","/select([[:space:]\*\/])/i","/update([[:space:]\*\/])/i","/replace([[:space:]\*\/])/i","/delete([[:space:]\*\/])/i","/drop([[:space:]\*\/])/i","/outfile([[:space:]\*\/])/i","/dumpfile([[:space:]\*\/])/i","/load_file\(/i","/substring\(/i","/ascii\(/i","/hex\(/i","/ord\(/i","/char\(/i");
		
		$replace = array('unio&#110;','selec&#116;\\1','updat&#101;\\1','replac&#101;\\1','delet&#101;\\1','dro&#112;\\1','outfil&#101;\\1','dumpfil&#101;\\1','load_fil&#101;(','substrin&#103;(','asci&#105;(','he&#120;(','or&#100;(','cha&#114;(');
		$_kw=preg_replace($search, $replace, $_kw);
		
		$condition=array();
		$extra='';
		
		$condition['_type']=$_type;
		$condition['_kw']=$_kw;
		
		
		switch($_type){
			case 'title':
			$return=$this->s_0->mylist_title($condition,$extra);
			break;
			case 'attr':
			$return=$this->s_0->mylist_attr($condition,$extra);
			break;
			case 'word':
			$return=$this->s_0->mylist_word($condition,$extra);
			break;
		}
		
		include($this->viewer_dir.'search/search_.php');
	}
//
}